package com.android.examplelist;

import com.special.ResideMenuDemo.MenuActivity;

import uk.co.senab.photoview.sample.LauncherActivity;
import android.app.ListActivity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends ListActivity {

	public static final String[] options = { "ListView多选删除效果", "夜间模式和广播", "原生actionbar返回和superCardToast", 
												"supertooltips", "弹出试图AppMsg", "MessageBar", "自定义actionbar", 
												"AsyncHttpClient使用", "DrawerLayout全屏", "SwipeRefreshLayout", "SwipeBackActivity", 
												"DialogFragment", "CustomLoading", "ViewPager背景联动", "photoview", "ResideMenu", 
												"Fragment Http回调", "弹性效果", "Bootstrap", "ORMLITE", "AndroidAnnotations"};

	
    private IntentFilter filter;
    
	
    private BroadcastReceiver receiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            System.out.println("BroadcastReceiver" + intent.getAction());
        }
    };
    
    
    private void bindReceiver() {
        filter = new IntentFilter();
        filter.addAction(BroadcastType.BROADCAST_TEST);
        filter.addAction(BroadcastType.BROADCAST_LOGOUT_SUCCESSFULLY);
        filter.addAction(BroadcastType.BROADCAST_LOGOUT_FAILED);
        registerReceiver(receiver, filter);
    }

	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		//getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);  // 覆盖模式 actionBar相当于漂浮在activity之上，不干预activity的布局。
		
		setContentView(R.layout.activity_main);
		bindReceiver();
		
		
		
		
		
		setListAdapter(new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, options));
	}

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		
		//System.out.println(position);
		Intent intent = null;
		if (position == 0) {
			intent = new Intent(this, MultiChoiceModeActivity.class);
		} else if (position == 1){
			intent = new Intent(this, ThemeActivity.class);
		} else if (position == 2) {
			intent = new Intent(this, ActionBarActivity.class);
		} else if (position == 3) {
			intent = new Intent(this, SuperToolTipActivity.class);
		} else if (position == 4) {
			intent = new Intent(this, AppMsgActivity.class);
		} else if (position == 5) {
			intent = new Intent(this, MessageBarActivity.class);
		} else if (position == 6) {
			intent = new Intent(this, CustomActionBarActivity.class);
		} else if (position == 7) {
			intent = new Intent(this, AsyncHttpClientActivity.class);
		} else if (position == 8) {
			intent = new Intent(this, DrawerActivity.class);
		} else if (position == 9) {
			intent = new Intent(this, SwipeRefreshActivity.class);
		} else if (position == 10) {
			intent = new Intent(this, SwipeBackDemoActivity.class);
		} else if (position == 11) {
			intent = new Intent(this, DialogFragmentActivity.class);
		} else if (position == 12) {
			intent = new Intent(this, CustomLoadingActivity.class);
		} else if (position == 13) {
			intent = new Intent(this, ParallaxViewPagerActivity.class);
		} else if (position == 14) {
			intent = new Intent(this, LauncherActivity.class);
		} else if (position == 15) {
			intent = new Intent(this, MenuActivity.class);
		} else if (position == 16) {
			intent = new Intent(this, FragmentCallbackActivity.class);
		} else if (position == 17) {
			intent = new Intent(this, StretchActivity.class);
		} else if (position == 18) {
			intent = new Intent(this, BootstrapActivity.class);
		} else if (position == 19) {
			intent = new Intent(this, OrmliteActivity.class);
		} else if (position == 20) {
			intent = new Intent(this, AndroidAnnotationsActivity_.class);
		}
		
		startActivity(intent);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	
    @Override
    public void onDestroy() {
        super.onDestroy();
        unregisterReceiver(receiver);
    }

}
